package kr.hkit.androidcomplete02.ch18;

import kr.hkit.androidcomplete02.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

public class ApplicationTest extends Activity {
	static final String TAG="APPLICATION";
	
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ch18_application);
		updateNowMode();
	}
	
	public void mOnClick(View v){
		ApplicationEx app = (ApplicationEx) getApplication();
		switch(v.getId()){
		case R.id.ch18_btnbegineer:
			app.setmMode(ApplicationEx.BEGINEER);
			break;
		case R.id.ch18_btnprofessor:
			app.setmMode(ApplicationEx.PROFESSIONAL);
			break;
		}
		updateNowMode();
	}
	
	private void updateNowMode() {
		TextView tv = (TextView) findViewById(R.id.ch18_mode);
		ApplicationEx app = (ApplicationEx) getApplication();
		
		if (app.getmMode() == ApplicationEx.BEGINEER){
			tv.setText("현재 모드 : 초보자 모드");
		}else{
			tv.setText("현재 모드 : 전문가 모드");
		}
	}
}
